CREATE TABLE [dbo].[ContactLog]
(
[ContactLogKey] [uniqueidentifier] NOT NULL,
[ContactKey] [uniqueidentifier] NOT NULL,
[SourceCodeCode] [nvarchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] [nvarchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[OutputOn] [datetime] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[CreatedByUserKey] [uniqueidentifier] NOT NULL,
[OrganizationKey] [uniqueidentifier] NOT NULL,
[MarkedForDeleteOn] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ContactLog] ADD CONSTRAINT [PK_ContactLog] PRIMARY KEY CLUSTERED ([ContactLogKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ContactLog_ContactKey] ON [dbo].[ContactLog] ([ContactKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ContactLog_CreatedByUserKey] ON [dbo].[ContactLog] ([CreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ContactLog_OrganizationKey] ON [dbo].[ContactLog] ([OrganizationKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ContactLog] ADD CONSTRAINT [FK_ContactLog_ContactMain] FOREIGN KEY ([ContactKey]) REFERENCES [dbo].[ContactMain] ([ContactKey])
GO
ALTER TABLE [dbo].[ContactLog] ADD CONSTRAINT [FK_ContactLog_OrganizationMain] FOREIGN KEY ([OrganizationKey]) REFERENCES [dbo].[OrganizationMain] ([OrganizationKey])
GO
ALTER TABLE [dbo].[ContactLog] ADD CONSTRAINT [FK_ContactLog_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO